package com.zjsd.sqeybusiness.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zjsd.sqeybusiness.domain.Depttask;
import com.zjsd.sqeybusiness.service.IDepttaskService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 部门销售任务Controller
 *
 * @author Zheng
 * @date 2021-07-14
 */
@RestController
@RequestMapping("/sqeybusiness/depttask")
public class DepttaskController extends BaseController
{
    @Autowired
    private IDepttaskService depttaskService;

    /**
     * 查询部门销售任务列表 @PreAuthorize("@ss.hasPermi('sqeybusiness:depttask:list')")
     */

    @GetMapping("/list")
    public TableDataInfo list(Depttask depttask)
    {
        // startPage();
        List<Depttask> list = depttaskService.selectDepttaskList(depttask);
        return getDataTable(list);
    }

    /**
     * 导出部门销售任务列表
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:depttask:export')")
    //@Log(title = "部门销售任务", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Depttask depttask)
    {
        List<Depttask> list = depttaskService.selectDepttaskList(depttask);
        ExcelUtil<Depttask> util = new ExcelUtil<Depttask>(Depttask.class);
        return util.exportExcel(list, "depttask");
    }

    /**
     * 获取部门销售任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:depttask:query')")
    @GetMapping(value = "/{depttaskid}")
    public AjaxResult getInfo(@PathVariable("depttaskid") Long depttaskid)
    {
        return AjaxResult.success(depttaskService.selectDepttaskById(depttaskid));
    }

    /**
     * 新增部门销售任务
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:depttask:add')")
    //@Log(title = "部门销售任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Depttask depttask)
    {

        return toAjax(depttaskService.insertDepttask(depttask));
    }

    /**
     * 修改部门销售任务
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:depttask:edit')")
    //@Log(title = "部门销售任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Depttask depttask)
    {
        return toAjax(depttaskService.updateDepttask(depttask));
    }

    /**
     * 删除部门销售任务
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:depttask:remove')")
    //@Log(title = "部门销售任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{depttaskids}")
    public AjaxResult remove(@PathVariable Long[] depttaskids)
    {
        return toAjax(depttaskService.deleteDepttaskByIds(depttaskids));
    }
}
